<template>
  <div>
    <!-- <h1>渲染数据</h1> -->
    <ul>
      <!-- <li><span>吃饭</span><button>删除</button></li> -->
      <li v-for="(item, index) in arr" :key="index">
        <span>{{ item }}</span>
        <button @click="del(index)">删除</button>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  name: "",
  props: ["arr"],
  data() {
    return {};
  },

  components: {},

  computed: {},

  beforeMount() {},

  mounted() {},

  methods: {
    del(index) {
      //   console.log(index);
      //触发自定义事件getIndex
      this.$emit("getIndex", index);
    },
  },

  watch: {},
};
</script>
<style lang='css' scoped>
* {
  margin: 0;
  padding: 0;
}
ul {
  width: 300px;
  margin: 0 auto;
}
li {
  margin-top: 10px;
  display: flex;
  justify-content: space-around;
  height: 30px;
  /* border: 1px solid black; */
}
</style>